var ejs = require('ejs')
	path = require('path'),
	express = require('express'),
	log = require('./router/log'),
	reg = require('./router/reg'),
	cheerio = require('./cheerio'),
	index = require('./router/index'),
	game = require('./router/game'),
	upfiles = require('./upfiles'),
	up = require('./router/up'),
	bodyParser = require('body-parser'),
	session = require('express-session'),
	cookieParser = require('cookie-parser'),
	app = express();

/**
*	app set
*/
app.use(bodyParser.json());
app.use(cookieParser());
app.use(bodyParser.urlencoded({ extended: true }));
app.engine('.html', require('ejs').__express);  
app.set('view engine', 'html');
app.use(express.static('public'));
app.use(session({
	secret: 'key',
	resave: true,
	// name:'info',
	saveUninitialized: true,
	cookie:{
		
	}
}));

/*
* cheerio baidu pan
*/
app.get('/cheerio',function(req, res){
	var t = req.query.text;
	cheerio.getssss(t,function(url){
		res.header({'Content-Type':'text/html;charset=UTF-8'})
		res.json(url);
	});
});

/*
*	配置路由
*/
app.use('/',index);
app.use('/login',log);
app.use('/reg',reg);
app.use('/up',up);
app.use('/game',game);

/*
*	配置404页面
*/
app.use(function(req, res, next) {
	res.status(404).render('404',{});
});

app.listen(3000);